#PBS -N 01A_fastqc_raw
#PBS -A GT-wratcliff3
#PBS -q inferno
#PBS -l nodes=1:ppn=6
#PBS -l pmem=4gb
#PBS -l walltime=1:00:00
#PBS -j oe
#PBS -o logs/01A_fastqc_raw.out
    
# change to project directory
PROJECT_DIR=$PBS_O_WORKDIR
echo "Changing directory to ${PROJECT_DIR}…"
cd $PROJECT_DIR
     
# activate environment
PIPELINE_ENV=`basename scripts/*.yml .yml`
echo "Activating conda environment ${PIPELINE_ENV}…"
source activate $PIPELINE_ENV
    
# extract sample name
samplenames=(`cat raw_data/samplenames.txt`)
sampleindex=$PBS_ARRAYID
samplename=${samplenames[$(($sampleindex-1))]}
     
echo -e "\n########## Start processing sample ${sampleindex}: ${samplename} ##########\n"

echo -e "\n########## Starting FastQC of raw reads ##########\n"

# input/output
in=raw_data
in_R1=$in/${samplename}_R1.fastq.gz
in_R2=$in/${samplename}_R2.fastq.gz
out=results/01A_fastqc_raw
mkdir -p $out

# main
fastqc \
$in_R1 $in_R2 \
-o $out \
-t $PBS_NP

